package cn.csxw.openchina.dagger2.presenter;

import java.util.List;

import javax.inject.Inject;

import cn.csxw.openchina.entity.bean.EventBean;
import cn.csxw.openchina.entity.bean.OsChinaBean;
import cn.csxw.openchina.entity.bean.PostBean;
import cn.csxw.openchina.ui.activity.RecentlyDetailActivity;
import retrofit2.Call;

/**
 * 发现---》活动--》近期活动--》详情活动
 */

public class RecentlyDetailActivityPresenter extends BasePresenter {
    RecentlyDetailActivity mRecentlyDetailActivity;
    @Inject
    public RecentlyDetailActivityPresenter(RecentlyDetailActivity recentlyDetailActivity) {
        mRecentlyDetailActivity = recentlyDetailActivity;
    }

    @Override
    protected void processData(OsChinaBean data) {
        if (data!=null){
            PostBean post = data.post;
            if (post!=null){
                //带参过去  好进行数据的设置
                mRecentlyDetailActivity.doNetWork(post);
            }
        }

    }

    @Override//网络数据
    public void callNetWork(Object... params) {
        if(params.length!=1||!(params[0] instanceof String)){
            throw new IllegalArgumentException("在活动详情中要填入参数");
        }
        //GET: http://www.oschina.net/action/api/post_detail?id=243072
        Call<OsChinaBean> postDetailInfo = mOsChinaServer.getPostDetailInfo((String) params[0]);
        postDetailInfo.enqueue(mCallback);

    }
}
